package com.kexun.lds;

public class Chihuo extends Thread{
    private  Baozi bz;
    public Chihuo(Baozi bz){
        this.bz=bz;
    }


    @Override
    public void run() {
        while(true){

            synchronized (bz){
                if(bz.flag==false){

                    try {
                        bz.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                //被唤醒之后执行  吃包子

                System.out.println("吃货吃包子");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                bz.flag=false;
                bz.notify();
                System.out.println("吃完了 ");


            }


        }
    }
}
